package com.android.gufengmall.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.android.gufengmall.R;
import com.android.gufengmall.bean.ApparelBean;
import com.android.gufengmall.gen.CommentBean;
import com.android.gufengmall.utils.LogUtils;

import java.util.List;

/**
 * 主页的古文化知识适配器
 */
public class CommentAdapter extends RecyclerView.Adapter<CommentAdapter.CommentViewHolder> {

    private Context mContext;
    private List<CommentBean> mCommentBeans;

    public CommentAdapter(Context context, List<CommentBean> commentBeans) {
        mContext = context;
        mCommentBeans = commentBeans;
    }

    @NonNull
    @Override
    public CommentViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new CommentViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_comment,parent,false));
    }

    @Override
    public void onBindViewHolder(@NonNull CommentViewHolder holder, int position) {
        CommentBean commentBean = mCommentBeans.get(position);
        if (commentBean != null) {
            holder.mTvTitle.setText(commentBean.getComment());
        }
    }

    @Override
    public int getItemCount() {
        if (mCommentBeans.size() != 0) {
            return mCommentBeans.size();
        } else {
            return 0;
        }
    }

    public class CommentViewHolder extends RecyclerView.ViewHolder {

        private TextView mTvTitle;

        public CommentViewHolder(@NonNull View itemView) {
            super(itemView);

            mTvTitle = itemView.findViewById(R.id.tv_title);
        }
    }
}
